<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    pageContext.setAttribute("root", request.getContextPath());
%>
<html>
<head>
    <title>查询所有员工</title>
    <script type="text/javascript" src="${root}/static/js/jquery.min.js"></script>
    <link href="${root}/static/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="${root}/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h1>CRUD</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-10">
            <button class="btn btn-primary">编辑</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>
    <div class="row">
        <table class="table">
            <tr>
                <th>id</th>
                <th>name</th>
                <th>gender</th>
                <th>email</th>
                <th>dep</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${pageemps.list}" var="emp">
                <tr>
                    <td>${emp.id}</td>
                    <td>${emp.name}</td>
                    <td>${emp.gender}</td>
                    <td>${emp.email}</td>
                    <td>${emp.dep.depname}</td>
                    <td>
                        <button class="btn btn-primary btn-sm">新增</button>
                        <button class="btn btn-danger btn-sm">删除</button>
                    </td>
                </tr>
            </c:forEach>
        </table>

    </div>
    <div class="row">
        <div class="col-md-6">
            当前第${pageemps.pageNum}页，总共${pageemps.pages}页，总记录数有${pageemps.total}条。
        </div>
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li><a href="${root}/emps?pn=1">首页</a></li>
                    <c:if test="${pageemps.hasPreviousPage}">
                        <li>
                            <a href="${root}/emps?pn=${pageemps.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:forEach items="${pageemps.navigatepageNums}" var="pagenums">
                        <c:if test="${pagenums==pageemps.pageNum}">
                            <li class="active"><a href="#">${pagenums}</a></li>
                        </c:if>
                        <c:if test="${pagenums!=pageemps.pageNum}">
                            <li><a href="${root}/emps?pn=${pagenums}">${pagenums}</a></li>
                        </c:if>
                    </c:forEach>
                    <c:if test="${pageemps.hasNextPage}">
                        <li>
                            <a href="${root}/emps?pn=${pageemps.pageNum+1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <li><a href="${root}/emps?pn=${pageemps.pages}">尾页</a></li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
